'''
Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
Date: 2025-07-19 16:46:41
LastEditors: duliang thinktanker@163.com
LastEditTime: 2025-08-16 11:57:16
FilePath: 
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
# from pywechat.WechatTools import Tools

# Tools.set_wechat_as_environ_path()
from pywechat import listen_on_chat, check_new_message
import os
import time


filesave_folder = r".\data\file"
mediasave_folder = r".\data\imagevideo"
if not os.path.exists(filesave_folder):
    os.makedirs(filesave_folder)
if not os.path.exists(mediasave_folder):
    os.makedirs(mediasave_folder)
while 1:
    contents, senders, types = listen_on_chat(friend='就餐群',
                                              duration='1min',
                                              save_file=True,
                                              file_folder=filesave_folder,
                                              save_media=True,
                                              media_folder=mediasave_folder)
    if contents:
        print(contents, senders, types)
        with open('diancan.txt', "a+", encoding='utf8') as f:
            f.write(f'{contents},{senders},{types},{int(time.time())}\n')
    else:
        print("没记录")
    # times.sleep(000)
# from pywechat import NativeSaveFile
# from pywechat import check_new_message

# filesave_folder = r"E:\Desktop\文件保存"
# newMessages = check_new_message(duration='5min',
#                                 save_file=True,
#                                 target_folder=filesave_folder)
#newMessages是[{'好友名称':'路人甲','好友类型':'群聊,好友或公众号','新消息条数':xx,'消息内容':[],'消息类型':[]}]
#格式的list[dict]
